#include<iostream>
using namespace std;

  struct ListNode {
      int val;
      ListNode *next;
      ListNode() : val(0), next(nullptr) {}
      ListNode(int x) : val(x), next(nullptr) {}
      ListNode(int x, ListNode *next) : val(x), next(next) {}
  };
 
class Solution {
public:
    ListNode* trainingPlan(ListNode* head, int cnt) {
        ListNode* cur = head;
        int num = 0;
        while (cur) {
            num++;
            cur = cur->next;
        }
        cnt = num - cnt;
        cur = head;
        if (cnt < 0)
            return nullptr;

        while (cnt--) {
            cur = cur->next;
        }
        return cur;
    }
};